<template>
  <div class="index" v-if="data">
    <qyb-header></qyb-header>队员
    <ul>
      <li v-for="(item,index) in data.userList" :key="index">
        <div class="team-item">名字：{{item.nickname}}</div>
        <div class="team-item">位置：{{item.positionType}}</div>
      </li>
    </ul>
    <pre>
      {{data}}
    </pre>
    <router-link :to="{name:'login'}">login</router-link>
  </div>
</template>
<script>
import Vue from "vue";
export default {
  data() {
    return {
      data: null,
      hehe: true,
      user: {
        lastName: "ggs"
      }
    };
  },
  watch: {
    $route() {
      // console.log('indexss');
    }
  },
  async mounted() {
    let { data } = await this.$http.get(`/api/team/${this.$route.params.id}`);
    this.data = data;
  },
  beforeRouteEnter(to, from, next) {
    console.log(to);
    console.log(Vue.$http);
    next(vm => {
      vm.haha();
    });
  },
  beforeRouteUpdate(to, from, next) {
    next();
  },
  methods: {
    haha() {
      console.log(2);
    },
    ceshi() {
      this.$router.push({
        name: this.$route.name,
        query: {
          hehe: +new Date()
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
@import "./item.scss";
</style>